#pragma once

#include "molecular_atom.h"
#include "models/atom_interface/ai_proc_info_fetcher.h"
#include "base/system/process_walker.h"

class ProcInfoFetcher :
    public M::Atom
{
public:
    ProcInfoFetcher();
    virtual ~ProcInfoFetcher();

    virtual M::String name() const { return PAN_PROC_INFO_FETCHER; }
    virtual bool OnEvent(const M::AtomEndPoint &oSrcAtom, int nEventId, void *pParams);
    virtual bool OnExecute(const M::AtomEndPoint &oSrcAtom, int nFuncId, void *pParams, void *pIOParams);

protected:
    bool OnGetWatchProcInfo(ProcInfo *pProcInfo);
    bool OnGetWatchProcInfo2(ProcInfo2 *pProcInfo2);
    bool OnGetWatchmageInfo(ImageInfo *pImageInfo);
    bool OnFetchProcInfo(DWORD nPid, ProcInfo *pProcInfo);
    bool OnFetchProcInfo2(DWORD nPid, ProcInfo2 *pProcInfo2);
    bool OnFetchImageInfo(TCHAR *pImagePath, ImageInfo *pImageInfo);

    bool RetrieveInfo();
    void ResetInfo();
    bool FetchProcInfo(PROCESSENTRY32 *pEntry, ProcInfo &oProcInfo);
    bool FetchProcInfo2(PROCESSENTRY32 *pEntry, ProcInfo2 &oProcInfo);
    bool FetchImageInfo(TCHAR *pImagePath, ImageInfo &oImageInfo);

private:
    DWORD m_dwPid;
    ProcInfo2 m_oProcInfo;
    ImageInfo m_oImageInfo;
};